<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/pub/head_latest.inc"%>
    <title>MetadataExpression list</title>
</head>
<body>
  <!-- Search Form -->
  <div id="mainsearch" style=" width:98%">
    <div class="searchtitle">
        <span>搜索</span><img src="${baseURL}/themes/default/icons/32X32/searchtool.gif" />
        <div class="togglebtn"></div> 
    </div>
    <div class="navline" style="margin-bottom:4px; margin-top:4px;"></div>
    <div class="searchbox">
        <form id="formsearch" class="l-form" method="get">
        	<table>
					<tr>
						 						<td align="right" class="l-table-edit-td"></td>
						<td align="left" class="l-table-edit-td" style="width: 160px">
							<input  name="" type="text" ltype=""
							class="field" />
						</td>
						<td align="left" class="l-table-edit-td"></td>
												<td align="left" class="l-table-edit-td"></td> 
						<td align="left" class="l-table-edit-td">
							<button type="button" id="btnSearch" class="l-button l-button-submit"><i class="fa fa-search"></i> 搜索</button>
						</td>
						<td align="left" class="l-table-edit-td">
							<button type="reset" id="btnReset" class="l-button l-button-test" ><i class="fa fa-exchange"></i> 重置</button>
						</td>
					</tr>
				</table>
        </form>
    </div>
  </div>
 <!-- Grid List-->
<div id="maingrid"></div> 

  <script type="text/javascript">
  
  	  function badousoft(){}
		badousoft.ajax=function(s){
		    jQuery.ajax(s);
		}	
		
  		var baseUrl = '${baseURL}/report/metadataexpression/metadataexpression';
      //List 
      var grid = $("#maingrid").ligerGrid({ 
          columns: [
           				  				        					        	 					   {display:"",name:"name",width:150,type:"String",align:"left",isSort : true}
				        	 		             
   		  ],
          dataAction: 'server',toolbar: {},
          url:  baseUrl+'list/listJSON.do', sortName: 'code',
          width: '98%', height: '100%',heightDiff:-10, checkbox: true,
          pageParmName:"pageNo",pageSizeOptions:[${pageOptions}],pagesizeParmName:"perPageSize",
          rowHeight:23,rownumbers:true,isScroll:true,sortnameParmName:"sortName",
          sortorderParmName:"sortOrder",checkbox:true,pageSize: ${pageSize}
      });

      //DoubleClick
      LG.setGridDoubleClick(grid, FF_ModifyClickEvent);
      
      
      //Load toolbar
      LG.createToolbarButton(grid, [{id : "add", name : "新增", clickEvent : FF_AddClickEvent, icon : "/silkicons/add.png"},
      								{id : "modify", name : "修改", clickEvent : FF_ModifyClickEvent, icon : "/silkicons/application_edit.png"},
      								{id : "delete", name : "删除", clickEvent : FF_DeletedClickEvent, icon : "/silkicons/delete.png"}]);

	  //搜索事件
      $("#btnSearch").click(function(e){
    	  var json = LG.bulidFilterParams($("#formsearch"));
          grid.set('parms', json);
            //采用原来的请求地址，带上参数加载数据
		  grid.loadData();
      });
  	  
  	   //重置事件
      $("#btnReset").click(function(e){
           grid.set('parms', null);
            //采用原来的请求地址，带上参数加载数据
		   grid.loadData();
      });
	  
	   $("#formsearch").ligerForm();
	  
      //Toolbar
      //Add Event
      function FF_AddClickEvent(btnItem){
      	parent.f_addTab("MetadataExpressionEdit", 'MetadataExpression', baseUrl+'edit/edit.do?menuId=${param.menuId}');
      }
       //Modify Event
      function FF_ModifyClickEvent(btnItem){
      	var row = grid.getLastSelected();
      	if (!row) { alert("Selected Before Operate!"); return false;}
      	      	parent.f_addTab("MetadataExpressionEdit", 'MetadataExpression', baseUrl+'edit/edit.do?menuId=${param.menuId}&id=' + row.id);
      }
      //Delete Evvent
      function FF_DeletedClickEvent(btnItem){
      	var selectedRow = grid.getCheckedRows();
      	if (!selectedRow || !selectedRow.length) { alert("Selected Before Operate!"); return false;}
      	jQuery.ligerDialog.confirm('Delete?', function (confirm) {
              if (confirm){
              	 badousoft.ajax({
   					type: "GET",
   					url: baseUrl+"delete/delete.do",
   					dataType : "json",
   					data: "ids="+LG.serialIdParam(selectedRow),
   					beforeSend: function (){
		                LG.loading = true;
		                LG.showLoading('Operating...');
		            },
		            complete: function (){
		                LG.loading = false;	  
		                LG.hideLoading();
		            },
   					success: function(msg){
     					if(msg && msg.hasOk){
     						 grid.loadData();
     						 alert('Success!');
     					}else{
     						alert("Fail!Message:\n"+msg.message+"\nContract with Manager!");
     					}
   					}
 				 });
              }
        });
      }
  </script>
</body>
</html>